package cn.bonoon.entities;

import java.util.Date;
import java.util.List;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;

import cn.bonoon.kernel.io.FileSize;
import cn.bonoon.kernel.io.StoragePersistable;
import cn.bonoon.kernel.util.StringHelper;

/**
 * 一次导入的文件，里面会包括多个原始数据
 * 
 * 数据的导入是一次性的，不能再对这些数据进行修改，如果数据有问题，则需要重新导入
 * @author jackson
 *
 */
@Entity
@Table(name = "t_rdtimport", catalog = "db_rawdata")
public class RawdataImportEntity extends RawdataImportExportEntity implements StoragePersistable{

	private static final long serialVersionUID = -6702861757547911438L;
	
	
	
	/** 统筹管理中创建项目时的名字 */
	@Column(name = "C_PROJECTNAME")
	private String projectName;
	
	/** 对应统筹管理中项目的id */
	@Column(name = "C_OVERALLPROJECTID")
	private Long overallProjectId;
	
	/**
	 * 仅添加用于确认医疗保险、养老保险的保障年度是否填写
	 * 未确认为0
	 * 确认为1
	 * 后续数据为2，不需选择年度了
	 */
	@Column(name = "C_INSUSTATUS")
	private int insuStatus;
	/** 保障年度	保障学年0-2016年秋季-2017年春季学年，1-2017年秋季-2018年春季学年 */
	@Column(name = "C_INSUREDYEAR")
	private Integer insuredYear;

	/** 每导入一次文件，还可以有多个(证明)材料 */
	@OneToMany(mappedBy = "subject")
	private List<RawdataImportMaterial> materials;
	
	/** 原来被导入的文件的名称 */
	@Column(name = "C_NAME", length = 200)
	private String name;
	
	/** 文件被保存的路径，如果需要！也可能不会保存被导入的文件 */
	@Column(name = "C_PATH", length = 512)
	private String path;
	
	/** 正确导入的有多少条数据 */
	@Column(name = "C_CORRECTCOUNT")
	private int correctCount;
	
	/** 处理导入这个文件的耗时 */
	@Column(name = "C_CONSUMING")
	private long consuming;
	
//  ----  2017-8-22  以下是新增加的字段
	@Column(name = "C_FILENAME", length = 200)
	private String filename;
	@Column(name = "C_SIZE")
	private Long size;
	@Column(name = "C_CHECKEDCOUNT")
	private Integer checkedCount;
	@Temporal(TemporalType.TIMESTAMP)
	@Column(name = "C_CHECKEDAT")
	private Date checkedAt;
	@Column(name = "C_POSTFIX", length = 10)
	private String postfix;
	
	/** 文件是否禁用  默认为否   禁用时村级将不能进行处理导入 */
	@Column(name = "C_FORBID")
	private boolean forbid;
	
	@Column(name = "C_MD5CODE")
	private String md5Code;
	
	public RawdataImportEntity() {
		this.forbid = true;
		this.insuStatus=2;
	}

	@Override
	public boolean hasFile() {
		return StringHelper.isNotEmpty(path);
	}
	
	public List<RawdataImportMaterial> getMaterials() {
		return materials;
	}

	public void setMaterials(List<RawdataImportMaterial> materials) {
		this.materials = materials;
	}

	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	public String getPath() {
		return path;
	}

	public void setPath(String path) {
		this.path = path;
	}

	public int getCorrectCount() {
		return correctCount;
	}

	public void setCorrectCount(int correctCount) {
		this.correctCount = correctCount;
	}

	public long getConsuming() {
		return consuming;
	}

	public void setConsuming(long consuming) {
		this.consuming = consuming;
	}

	
	@Override
	public void setFilename(String filename) {
		this.filename = filename;
	}

	@Override
	public String getFilename() {
		return filename;
	}

	@Override
	public void setSize(Long size) {
		this.size = size;
	}

	@Override
	public Long getSize() {
		return size;
	}

	@Override
	public String toSize() {
		return FileSize.valueOf(size).toString();
	}

	@Override
	public void setCheckedCount(Integer checkedCount) {
		this.checkedCount = checkedCount;
	}

	@Override
	public Integer getCheckedCount() {
		return checkedCount;
	}

	@Override
	public void setCheckedAt(Date checkedAt) {
		this.checkedAt = checkedAt;
	}

	@Override
	public Date getCheckedAt() {
		return checkedAt;
	}

	@Override
	public String getPostfix() {
		return postfix;
	}

	@Override
	public void setPostfix(String postfix) {
		this.postfix = postfix;
	}

	public boolean isForbid() {
		return forbid;
	}

	public void setForbid(boolean forbid) {
		this.forbid = forbid;
	}

	public int getInsuStatus() {
		return insuStatus;
	}

	public void setInsuStatus(int insuStatus) {
		this.insuStatus = insuStatus;
	}

	public Integer getInsuredYear() {
		return insuredYear;
	}

	public void setInsuredYear(Integer insuredYear) {
		this.insuredYear = insuredYear;
	}

	public String getProjectName() {
		return projectName;
	}

	public void setProjectName(String projectName) {
		this.projectName = projectName;
	}

	public Long getOverallProjectId() {
		return overallProjectId;
	}

	public void setOverallProjectId(Long overallProjectId) {
		this.overallProjectId = overallProjectId;
	}

	public String getMd5Code() {
		return md5Code;
	}

	public void setMd5Code(String md5Code) {
		this.md5Code = md5Code;
	}
	
	


}
